# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=kan-extensions
pkgname=haskell-kan-extensions
pkgver=5.2.5
pkgrel=84
pkgdesc="Kan extensions, Kan lifts, the Yoneda lemma, and (co)density (co)monads"
url="https://github.com/ekmett/kan-extensions/"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-adjunctions' 'haskell-comonad' 'haskell-contravariant'
         'haskell-distributive' 'haskell-free' 'haskell-invariant' 'haskell-profunctors'
         'haskell-semigroupoids' 'haskell-tagged' 'haskell-transformers-compat')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz")
sha512sums=('70303f23e4935ca662f5e094a0ab9c18997c5ff2896bbbe1c8f7d994002f75176457757ad8d4647699ea1cc28701c75cb10cb4fcbe81d8c2f3c71cf28244ca9c')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
